/*
 * OP_LOGIC.java
 *
 * Created on 3 de Mar�o de 2009, 13:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package compilador.analisadorSintatico.operacoes;

import compilador.analisadorLexico.Token;
import compilador.analisadorLexico.TokenClass;
import compilador.analisadorSintatico.Producao;
import compilador.analisadorSintatico.TokenReader;
import compilador.analisadorSintatico.simboloGramatical.NaoTerminal;
import compilador.analisadorSintatico.simboloGramatical.SimboloGramatical;

/**
 *
 * @author Joaquim Ranyere
 */
public class OP_LOGIC extends Producao {

    /** Creates a new instance of OP_LOGIC */
    public OP_LOGIC() {
    }

    public SimboloGramatical derivar() throws Exception {

        TokenReader tokenReader = TokenReader.getInstance();
        
        Token token = tokenReader.seeCurrent();

        NaoTerminal OP_LOGIC = new NaoTerminal(this.getClass().getSimpleName());

        if (token.getTokenClass().equals(TokenClass.OPERADOR) && token.getAtributo().equals("&&")) {
            OP_LOGIC.add(new OP_AND().derivar());
        } else if (token.getTokenClass().equals(TokenClass.OPERADOR) && token.getAtributo().equals("||")) {
            OP_LOGIC.add(new OP_OR().derivar());
        }
        simbolo = OP_LOGIC;

        return simbolo;
    }

    @Override
    public void setSimbolo() {
        super.simbolo = new NaoTerminal("OP_LOGIC");
    }
}
